home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Test2
- Caption = "Aardvark Software"
- ClientHeight = 5940
- ClientLeft = 1020
- ClientTop = 1455
- ClientWidth = 7305
- Height = 6315
- Left = 975
- LinkTopic = "frmTest2"
- ScaleHeight = 5940
- ScaleWidth = 7305
- Top = 1125
- Width = 7395
- Begin ComboBox cboType
- Height = 300
- Left = 2040
- TabIndex = 1
- Text = "Combo1"
- Top = 1260
- Width = 2895
- End
- Begin CommandButton Command1
- Caption = "Do It"
- Height = 495
- Left = 2160
- TabIndex = 0
- Top = 4560
- Width = 2535
- End
- Begin Label Label1
- Caption = "Type:"
- Height = 255
- Left = 360
- TabIndex = 2
- Top = 1320
- Width = 1095
- End
- Option Explicit
- Dim LostFocusActive As Integer
- Dim BeepOnError As Integer
- 'General Routine for Hashing item's id
- Sub AddressItem (Item_ID As String, Hash As Integer)
- Dim i As Integer
- If Len(Item_ID) > 1 Then
- Hash = 0
- For i = 1 To Len(Item_ID)
- Hash = Hash + Asc(Mid$(Item_ID, i, 1))
- Next i
- Hash = Hash Mod 17 ' a prime number
- Select Case Item_ID
- Case " " ' blank
- Hash = 0
- Case "0" To "9"
- Hash = 1
- Case Else
- Hash = 2
- End Select
- End If
- End Sub
- Sub cboType_LostFocus ()
- Dim Ans As Integer
- Dim i As Integer
- Dim lenType As Integer
- Dim NewCode As String
- Dim NewDescription As String
- If LostFocusActive <> -1 And LostFocusActive <> cboType.TabIndex Then Exit Sub
- LostFocusActive = -1
- If cboType.ListIndex > -1 Then Exit Sub ' all ok
- NewDescription = cboType.Text
- If NewDescription = "" Then
- If BeepOnError Then Beep
- MsgBox "Type may not be blank"
- cboType.SetFocus
- LostFocusActive = cboType.TabIndex
- Exit Sub
- End If
- ' a possible new value
- Ans = MsgBox(NewDescription & " is a new value, do you want to add it?", MB_YESNOCANCEL + MB_ICONQUESTION + MB_DEFBUTTON2)
- If Ans = IDNO Then ' he said no
- cboType.SelStart = 0
- cboType.SelLength = Len(cboType.Text)
- cboType.SetFocus
- LostFocusActive = cboType.TabIndex
- Exit Sub
- ElseIf Ans = IDCANCEL Then
- cboType.Text = ""
- cboType.ListIndex = -1
- Exit Sub
- End If
- End Sub
-